home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!xmission!inteleNET!usenet
- From: cjmorgan@intele.net (Jason V. Morgan)
- Newsgroups: comp.lang.c
- Subject: Re: String Upper/Lower--void main an error?
- Date: 20 Mar 1996 00:06:56 GMT
- Organization: inteleNET Internet Services
- Message-ID: <4ini70$8j@vodka.intele.net>
- References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net>
- NNTP-Posting-Host: 206.29.210.151
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- >>void main (void) {
- >
- >Oh, please! Read the FAQ to avoid posting crap like this.
- >
- >>char test[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
- >>char *p;
- >>
- >>printf ("%s\n", &test);
- >
- >&test ??? How about just test?
- >
- >>for (p = test; *p; *p++)
- >
- >And what do you think you are accomplishing with *p++ that p++ or ++p
- >wouldn't do???
- >
- >> if (isalpha(*p)) *p ^= 0x20; /* for ascii machines e.g. PC; use 0x40 for
- ebcdic machines e.g. IBM mainframe */
- >
- >isalpha() has not been declared. It takes an int and *p may be a signed
- >char, how about *(unsigned char *)p. Also, your code is toggling between
- >upper and lower case.
-
- >>printf ("%s\n", &test);
- >
- >There you go again with this &test thingy. Finally, you'll want a
- >"return 0;" after you've fixed the "void main" error.
-
- I don't thing that void main is really considered to be an error. Return
- values are only really necessary if they're going to mean anything. It is
- compilable (maybe I'm wrong and it's not portable). At least it was declared
- void so it didn't default to an int. You might as well say that it's an error
- because argc, argv, and env weren't passed (to be honest, I'm not sure if env
- is actually standard, I got it from the programmer's reference, not the
- standard).
- --Jason V. Morgan
-
-